package com.lincoln.cloud.servercenter.interfaces;

import com.lincoln.cloud.common.bean.CommonServerInfo;
import com.lincoln.cloud.common.bean.ServerMessage;

/**
 * 基本通信协议
 *
 * @author lincoln
 */
public interface CommunicationProtocol {
    /**
     * 协议初始化
     *
     * @return
     * @throws Exception
     */
    boolean init() throws Exception;

    /**
     * 发送消息
     *
     * @param serverMessage
     * @return
     */
    boolean sendMessage(ServerMessage serverMessage);

    /**
     * 资源服务器登陆
     *
     * @param deviceType
     * @param protocolType
     * @param name
     * @param httpPort
     * @return
     */
    boolean login(int deviceType, int protocolType, String name, int httpPort);

    /**
     * 资源服务器心跳处理
     *
     * @return
     */
    boolean checkHeart();

    /**
     * 根据app-name获取一个ip
     *
     * @param name
     * @return
     */
    boolean achieveServer(String name);

    /**
     * 获取app-name的服务
     *
     * @param name
     * @return
     * @throws Exception
     */
    boolean achieveServers(String name) throws Exception;

    /**
     * 通过id查询
     *
     * @param id
     * @return
     * @throws Exception
     */
    boolean achieveServer(int id) throws Exception;

    /**
     * 查询所有
     *
     * @return
     * @throws Exception
     */
    boolean achieveServers() throws Exception;

    /**
     * 更新信息
     *
     * @param commonServerInfo
     * @return
     * @throws Exception
     */
    boolean updateInfo(CommonServerInfo commonServerInfo) throws Exception;
}
